User blog:Lzlis/Unit stats
This article discusses technical information regarding how the core stats of HP, Attack, and Defense are calculated for the player's units. At the moment, I am focusing on base stats, not including any modifiers that happen during missions or as the result of abilities. I also present some synthesis comparing different rarities. Class Stats The principal factors in determining stats are the unit's class and level. Each class has a range for each stat (PlayerUnitTable.aar/ClassData.atb). The low value represents the stat of a (theoretical) level 0 unit, and the high value represents the stat of a max level unit. Max level varies by class -- for base classes (e.g. Soldier), it is 50. For class-evolved classes (e.g. Soldier Chief) it is 80. For awakened classes (e.g. Elite Soldier) it is 99. For classes with no evolution (e.g. Princess), it is also 80. (Max level is also explicitly listed in ClassData.atb.) For units that are at an intermediate level, the level 0 and max level values are interpolated linearly and rounded to the nearest integer (half-integers round up). Example: The stat ranges for Soldier are HP: 700, 1000; Attack: 150, 235; Defense: 100, 150. The max level is 50. If a soldier is level 12, the base stats are: *HP: round(700 + (1000 - 700) × 12/50) = round(772) = 772 *Attack: round(150 + (235 - 150) × 12/50 = round(170.4) = 170 *Defense: round(100 + (150 - 100) × 12/50 = round(112) = 112 Right off the bat, this provides an advantage for units with a higher rarity -- lower rarity units cannot reach as high of a level, so their maximum potential stats will be lower. For class evolved classes, it is only convention that the starting stats are greater than or equal to the maximum stats of the previous class. (For this reason, it makes a lot of sense that all classes capable of class evolution should max out at the same level 50, otherwise the stats would jump when class evolving.) "Junior" classes possessed by iron and bronze units are technically separate classes as well, but in practice these have the same stat ranges as the silver+ version of the class. Unit Stat Modifiers The secondary factor in determining stats is a set of modifiers possessed by the unit itself. Each unit has percentage modifier that applies to each of the three stats (in the GRs733a4 POST response). This modifier is applied to the class's stat value for the unit level (which is already rounded), and then rounded again to the nearest integer (half-integers round up). Example: Let's continue the example of a level 12 Soldier from before and suppose the soldier is Mercenary Crave. Crave's stat modifiers are HP: 111%; Attack: 112%; Defense: 107%. *HP: round(772 × 1.11) = round(856.92) = 857 *Attack: round(170 × 1.12) = round(190.4) = 190 *Defense: round(112 × 1.07) = round(119.84) = 120 The fact that two stages of rounding happen (once for the class stats, then again for the unit modifiers) is true. This is the reason why sometimes units' stat growths from level to level aren't as even as they could be. There is an additional small caveat that rarely comes into play. The game performs these numerical operations using native Javascript number operations. Javascript numbers are (supposed to be implemented by web browsers as) IEEE 754 double precision floating point numbers. In some cases, the representation can cause round off errors that affect the stats. As an example, look at Shao's attack at level 50. Base attack for a level 50 archer is 190, and Shao's modifier is 115%. Using ideal math: *Attack: round(190 × 1.15) = round(218.5) = 219 However, this is not the result that will arise from (naive) double precision floating point math. 1.15 cannot be represented exactly as a binary floating point number, and this difference is large enough, that when multiplied by 190, the result is slightly less than 218.5, so Shao's attack rounds down to 218. Out of all the stats listed on the wiki, the only places where this kind of error occurs are listed below. Note that these are all 115% modifiers except for Barrad's 113% defense which suggests that maybe 115% is a particularly bad number (although I haven't verified this mathematically). *Mehlis lv50 HP: -1 *Odette lv50 DEF: -1 *Odette lv50cc1 DEF: -1 *Zola lv50 HP: -1 *Barrad lv50 DEF: -1 *Sabinne lv50 DEF: -1 *Shao lv50 ATK: -1 Units of higher rarity tend to have better stat modifiers. The metric the game tends to use is the sum of the three stat modifiers. In general (particularly for units that can be summoned in the Shrine) the following is true: The most notable category of units that falls outside this rule are Platinum/Black event units. These units often have lower stat modifiers than other units of the same rarity. The other main category of units that falls outside the rule is non-human units. For example Elves tend to have lower overall stats, but faster attack speed, and stats highly specialized towards Attack and/or Defense (with less than 100% HP). Dwarves (if I can be permitted to extrapolate from one example) have high overall stats, but slower attack speed. I'll list all of the outliers for reference: Of course, while stat mod sum is a nice general metric, it certainly does not tell the whole story even in terms of stats -- different classes may not compare to one another, and within the same class, the distribution of stats is very important as well. Early Class Evolution Class evolution can be undertaken starting at level 30. However, changing class before level 50 incurs a penalty on the class-changed unit. This penalty is in the form of a flat percentage reduction of all three stats applied before the affection bonus. The reduction is rounded to the nearest integer (half-integers round up). The size of the penalty depends on how early the class change is. At level 30-31, the penalty is 10%, at 32-33 it is 9% and so on. The penalty decreases by 1% every two levels, reaching 0% at level 50. (This is field "AC" in the oS5aZ5ll POST response.) Example: Let's take Crave to level 30 and then class evolve him. If we had leveled Crave to 50 before class changing, we would get his normal level 1 Soldier Chief stats of HP: 1116; Attack: 264; Defense: 162. *HP: 1116 - round(1116 × 0.10) = 1116 - round(111.6) = 1004 *Attack: 264 - round(264 × 0.10) = 264 - round(26.4) = 238 *Defense: 162 - round(162 × 0.10) = 162 - round(16.2) = 146 As a convention, level 50 unevolved class stats are the same as level 0 evolved class stats. This means that a normal level 50 class evolution will gain a small amount of stats equivalent to a level-up in the new class. For early class evolution, this breaks down. For level 30 evolution, typically there is a significant jump in stats despite the 10% penalty, but this is not universal. Some classes will lose stats upon level 30 evolution (e.g. Samurai HP, Angel Attack, etc). Affection Bonus Affection bonus (or trust bonus for male units) provides an extra bonus to one or two stats as the unit's affection/trust is leveled up. (The game data actually has a space for a third affection stat to be boosted, but it isn't used.) Generally, iron/bronze units don't get affection boosts at all, silver and gold get one stat, and platinum and black get two stats. There are special cases though -- there is no inherent connection between rarity and affection bonus. The game data for this is all stored on a per-unit basis. Each affection bonus is controlled by type and single bonus number. (In the GRs733a4 POST response, these are BonusType and BonusNum.) The affection type is internally encoded as follows: The amount of bonus received is the bonus number scaled by the current affection amount rounded to the nearest integer (half-integers round up). The exception to this is that there is a jump between 99% and 100% affection -- at 100% affection/trust, the bonus number is scaled by 120% instead of 100%. Also, note that units that have not class-evolved are capped at 50% affection (except for units which cannot class-evolve like Summoners). Example: Let's continue with our level 12 Crave and suppose his trust is 40%. Crave's trust bonus is 40 to Attack. * Attack: 190 + round(40 × 0.40) = 190 + round(16) = 206 By convention, units of higher rarity get bigger bonuses. Also, female units get larger (in fact, usually double) bonuses compared to male units. Generally, affection bonuses follow the rules listed below. (Note that these are 100% values, not 120% values.) For platinum/black, units will either get a primary and secondary bonus, two balanced bonuses, or one single bonus. Prior to the 2016-08-02 balance patch, HP and defense bonuses were smaller, and there were also a few inconsistencies. The patch removed these inconsistencies; all units seem to fit the pattern perfectly now. Also worth noting is the Range affection bonus which a few Black units have. Range+17 appears to count as a secondary bonus for female Black units.